#! /bin/sh /usr/share/dpatch/dpatch-run
## 07_full_sonames.dpatch by  <david@evans>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad atlas-3.8.3~/CONFIG/src/Makefile atlas-3.8.3/CONFIG/src/Makefile
--- atlas-3.8.3~/CONFIG/src/Makefile	2009-08-25 08:09:25.000000000 -0700
+++ atlas-3.8.3/CONFIG/src/Makefile	2009-08-25 08:09:26.000000000 -0700
@@ -370,6 +370,13 @@
 install : $(INCINSTdir) $(LIBINSTdir) $(INCINSTdir)/atlas $(LIBINSTdir)/atlas
 	$(MAKE) -f Make.top install_inc INSTdir=$(INCINSTdir) 
 	$(MAKE) -f Make.top install_static_lib INSTdir=$(LIBINSTdir)
+install_headers : $(INCINSTdir) $(INCINSTdir)/atlas
+	$(MAKE) -f Make.top install_inc INSTdir=$(INCINSTdir) 
+install_static : $(LIBINSTdir) $(LIBINSTdir)/atlas
+	$(MAKE) -f Make.top install_static_lib INSTdir=$(LIBINSTdir) 
+install_shared : $(LIBINSTdir) $(LIBINSTdir)/atlas
+	$(MAKE) -f Make.top install_shared_lib INSTdir=$(LIBINSTdir) 
+
 
 confclean:
 	rm -f *core* *.o config?.out
diff -urNad atlas-3.8.3~/Make.top atlas-3.8.3/Make.top
--- atlas-3.8.3~/Make.top	2009-08-25 08:09:25.000000000 -0700
+++ atlas-3.8.3/Make.top	2009-08-25 08:09:26.000000000 -0700
@@ -288,6 +288,7 @@
 	touch include/dXover.h
 	touch include/sXover.h
 
+# XXX: we should use install tool here instead of those hacks
 install_inc:
 	cp $(INCSdir)/cblas.h $(INSTdir)/.
 	cp $(INCSdir)/clapack.h $(INSTdir)/.
@@ -312,10 +313,18 @@
 
 install_shared_lib:
 	for lib in atlas cblas f77blas lapack_atlas; do \
-		cp $(LIBdir)/lib$$lib.so $(INSTdir)/. ; \
+		cp $(LIBdir)/lib$$lib.so.3gf.0 $(INSTdir)/. ; \
+		( cd $(INSTdir) && ln -s lib$$lib.so.3gf.0 lib$$lib.so.3gf); \
+		( cd $(INSTdir) && ln -s lib$$lib.so.3gf lib$$lib.so); \
 		chmod 0644 $(INSTdir)/lib$$lib.so ;\
+		chmod 0644 $(INSTdir)/lib$$lib.so.3gf ;\
+		chmod 0644 $(INSTdir)/lib$$lib.so.3gf.0 ;\
 	done;
 	for lib in blas lapack; do \
-		cp $(LIBdir)/atlas/lib$$lib.so $(INSTdir)/atlas/. ; \
+		cp $(LIBdir)/atlas/lib$$lib.so.3gf.0 $(INSTdir)/atlas/. ; \
+		( cd $(INSTdir)/atlas/ && ln -s lib$$lib.so.3gf.0 lib$$lib.so.3gf); \
+		( cd $(INSTdir)/atlas/ && ln -s lib$$lib.so.3gf lib$$lib.so); \
 		chmod 0644 $(INSTdir)/atlas/lib$$lib.so ;\
+		chmod 0644 $(INSTdir)/atlas/lib$$lib.so.3gf ;\
+		chmod 0644 $(INSTdir)/atlas/lib$$lib.so.3gf.0 ;\
 	done;
diff -urNad atlas-3.8.3~/makes/Make.lib atlas-3.8.3/makes/Make.lib
--- atlas-3.8.3~/makes/Make.lib	2009-08-25 08:09:25.000000000 -0700
+++ atlas-3.8.3/makes/Make.lib	2009-08-25 08:11:25.000000000 -0700
@@ -1,12 +1,12 @@
 include Make.inc
 mySRCdir = $(SRCdir)/lib
 #
-# override with libatlas.so only when atlas is built to one lib
+# override with libatlas.so.3gf.0 only when atlas is built to one lib
 #
-DYNlibs = liblapack_atlas.so libf77blas.so libcblas.so libatlas.so 
-PTDYNlibs = liblapack_atlas.so libptf77blas.so libptcblas.so libatlas.so 
-CDYNlibs = liblapack_atlas.so libcblas.so libatlas.so 
-CPTDYNlibs = liblapack_atlas.so libptcblas.so libatlas.so 
+DYNlibs = liblapack_atlas.so.3gf.0 libf77blas.so.3gf.0 libcblas.so.3gf.0 libatlas.so.3gf.0 
+PTDYNlibs = liblapack_atlas.so.3gf.0 libptf77blas.so.3gf.0 libptcblas.so.3gf.0 libatlas.so.3gf.0 
+CDYNlibs = liblapack_atlas.so.3gf.0 libcblas.so.3gf.0 libatlas.so.3gf.0 
+CPTDYNlibs = liblapack_atlas.so.3gf.0 libptcblas.so.3gf.0 libatlas.so.3gf.0 
 
 VER=3.8.3
 tarnam = atlas$(VER)_$(ARCH)
@@ -31,44 +31,95 @@
 	$(GZIP) --best $(tarnam).tar
 	mv $(tarnam).tar.gz $(tarnam).tgz
 
+# Soft link creation
+# XXX: I cannot make default rule work for some reason...
+libatlas.so: libatlas.so.3gf
+	rm -f $@
+	ln -s $< $@ 
+
+libatlas.so.3gf: libatlas.so.3gf.0
+	rm -f $@
+	ln -s $< $@ 
+
+libcblas.so: libcblas.so.3gf
+	rm -f $@
+	ln -s $< $@ 
+
+libcblas.so.3gf: libcblas.so.3gf.0
+	rm -f $@
+	ln -s $< $@ 
+
+libf77blas.so: libf77blas.so.3gf
+	rm -f $@
+	ln -s $< $@ 
+
+libf77blas.so.3gf: libf77blas.so.3gf.0
+	rm -f $@
+	ln -s $< $@ 
+
+liblapack_atlas.so: liblapack_atlas.so.3gf
+	rm -f $@
+	ln -s $< $@ 
+
+liblapack_atlas.so.3gf: liblapack_atlas.so.3gf.0
+	rm -f $@
+	ln -s $< $@ 
+
+atlas/libblas.so: atlas/libblas.so.3gf
+	rm -f $@
+	(cd atlas && ln -s libblas.so.3gf libblas.so)
+
+atlas/libblas.so.3gf: atlas/libblas.so.3gf.0
+	rm -f $@
+	(cd atlas && ln -s libblas.so.3gf.0 libblas.so.3gf)
+
+atlas/liblapack.so: atlas/liblapack.so.3gf
+	rm -f $@
+	(cd atlas && ln -s liblapack.so.3gf liblapack.so)
+
+atlas/liblapack.so.3gf: atlas/liblapack.so.3gf.0
+	rm -f $@
+	(cd atlas && ln -s liblapack.so.3gf.0 liblapack.so.3gf)
+
+# Build rules
 ptshared :
-	- rm -f libatlas.so liblapack_atlas.so
-	$(MAKE) libatlas.so liblapack_atlas.so libptf77blas.so libf77blas.so \
-                libptcblas.so libcblas.so liblapack_atlas.so
+	- rm -f libatlas.so.3gf.0 liblapack_atlas.so.3gf.0
+	$(MAKE) libatlas.so.3gf.0 liblapack_atlas.so.3gf.0 libptf77blas.so.3gf.0 libf77blas.so.3gf.0 \
+                libptcblas.so.3gf.0 libcblas.so.3gf.0 liblapack_atlas.so.3gf.0
 shared :
-	- rm -f libatlas.so liblapack_atlas.so libf77blas.so libcblas.so liblapack_atlas.so
-	$(MAKE) libatlas.so liblapack_atlas.so libf77blas.so libcblas.so liblapack_atlas.so
+	- rm -f libatlas.so.3gf.0 liblapack_atlas.so.3gf.0 libf77blas.so.3gf.0 libcblas.so.3gf.0 liblapack_atlas.so.3gf.0
+	$(MAKE) libatlas.so.3gf.0 liblapack_atlas.so.3gf.0 libf77blas.so.3gf.0 libcblas.so.3gf.0 liblapack_atlas.so.3gf.0
 fullshared :
-	- rm -f atlas/libblas.so atlas/liblapack.so
-	$(MAKE) atlas/libblas.so atlas/liblapack.so
+	- rm -f atlas/libblas.so.3gf.0 atlas/liblapack.so.3gf.0
+	$(MAKE) atlas/libblas.so.3gf.0 atlas/liblapack.so.3gf.0
 cptshared :
-	- rm -f libatlas.so libclapack_atlas.so
-	$(MAKE) libatlas.so libclapack_atlas.so libptcblas.so libcblas.so
+	- rm -f libatlas.so.3gf.0 libclapack_atlas.so.3gf.0
+	$(MAKE) libatlas.so.3gf.0 libclapack_atlas.so.3gf.0 libptcblas.so.3gf.0 libcblas.so.3gf.0
 cshared :
-	- rm -f libatlas.so libclapack_atlas.so
-	$(MAKE) libatlas.so libclapack_atlas.so libcblas.so
+	- rm -f libatlas.so.3gf.0 libclapack_atlas.so.3gf.0
+	$(MAKE) libatlas.so.3gf.0 libclapack_atlas.so.3gf.0 libcblas.so.3gf.0
 
-libatlas.so : libatlas.a
-	ld $(LDFLAGS) -shared -soname libatlas.so -o libatlas.so \
+libatlas.so.3gf.0 : libatlas.a
+	ld $(LDFLAGS) -shared -soname libatlas.so.3gf -o $@ \
         --whole-archive libatlas.a --no-whole-archive -lc $(LIBS)
-liblapack_atlas.so : liblapack_atlas.a libatlas.so libcblas.so libf77blas.so
-	ld $(LDFLAGS) -shared -soname $@ -o $@ \
+liblapack_atlas.so.3gf.0 : liblapack_atlas.a libatlas.so libcblas.so libf77blas.so
+	ld $(LDFLAGS) -shared -soname liblapack_atlas.so.3gf -o $@ \
 	  --whole-archive liblapack_atlas.a  \
-	  --no-whole-archive -L. -lf77blas -lcblas -latlas -lm -c $(F77SYSLIB)
-libclapack_atlas.so : libclapack_atlas.a
-	ld $(LDFLAGS) -shared -soname liblapack_atlas.so -o liblapack_atlas.so \
+	  --no-whole-archive -L. -lf77blas -lcblas -latlas -lm -lc $(F77SYSLIB)
+libclapack_atlas.so.3gf.0 : libclapack_atlas.a
+	ld $(LDFLAGS) -shared -soname liblapack_atlas.so.3gf.0 -o liblapack_atlas.so.3gf.0 \
            --whole-archive libclapack_atlas.a
-libptf77blas.so : libptf77blas.a
+libptf77blas.so.3gf.0 : libptf77blas.a
 	ld $(LDFLAGS) -shared -soname $@ -o $@ --whole-archive libptf77blas.a \
            --no-whole-archive $(F77SYSLIB)
-libf77blas.so : libf77blas.a libcblas.so libatlas.so
-	ld $(LDFLAGS) -shared -soname $@ -o $@ \
+libf77blas.so.3gf.0 : libf77blas.a libcblas.so libatlas.so
+	ld $(LDFLAGS) -shared -soname libf77blas.so.3gf -o $@ \
 	  --whole-archive libf77blas.a \
           --no-whole-archive -L. -lcblas -latlas $(F77SYSLIB) -lm -lc
-libptcblas.so : libptcblas.a
+libptcblas.so.3gf.0 : libptcblas.a
 	ld $(LDFLAGS) -shared -soname $@ -o $@ --whole-archive libptcblas.a
-libcblas.so : libcblas.a libatlas.so
-	ld $(LDFLAGS) -shared -soname $@ -o $@ \
+libcblas.so.3gf.0 : libcblas.a libatlas.so
+	ld $(LDFLAGS) -shared -soname libcblas.so.3gf -o $@ \
 	  --whole-archive libcblas.a \
           --no-whole-archive -L. -latlas $(F77SYSLIB) -lm -lc
 
@@ -89,35 +140,35 @@
 	ar r $@ tmp/*.o
 	rm -rf tmp
 
-atlas/libblas.so: atlas/libblas.a libatlas.so
-	ld $(LDFLAGS) -shared -soname libblas.so -o $@ \
+atlas/libblas.so.3gf.0: atlas/libblas.a libatlas.so
+	ld $(LDFLAGS) -shared -soname libblas.so.3gf -o $@ \
 	   --whole-archive atlas/libblas.a \
            --no-whole-archive $(F77SYSLIB) -lm -lc
 
-atlas/liblapack.so: atlas/liblapack.a atlas/libblas.so
-	ld $(LDFLAGS) -shared -soname liblapack.so -o $@ \
+atlas/liblapack.so.3gf.0: atlas/liblapack.a atlas/libblas.so
+	ld $(LDFLAGS) -shared -soname liblapack.so.3gf -o $@ \
 	   --whole-archive atlas/liblapack.a \
            --no-whole-archive -L . -lblas $(F77SYSLIB) -lm -lc
 #
 # Builds one shared lib from all ATLAS files
 #
 fat_ptshared :                              # threaded target
-	ld $(LDFLAGS) -shared -soname libatlas.so -o libatlas.so \
+	ld $(LDFLAGS) -shared -soname libatlas.so.3gf.0 -o libatlas.so.3gf.0 \
         --whole-archive liblapack_atlas.a libptf77blas.a libptcblas.a libatlas.a \
            --no-whole-archive -lc $(F77SYSLIB) $(LIBS)
 fat_shared :                                # unthreaded target
-	ld $(LDFLAGS) -shared -soname libatlas.so -o libatlas.so \
+	ld $(LDFLAGS) -shared -soname libatlas.so.3gf.0 -o libatlas.so.3gf.0 \
         --whole-archive liblapack_atlas.a libf77blas.a libcblas.a libatlas.a \
            --no-whole-archive -lc $(F77SYSLIB) $(LIBS)
 #
 # Builds shared lib, not include fortran codes from LAPACK
 #
 fat_cptshared : libclapack_atlas.a                # threaded target
-	ld $(LDFLAGS) -shared -soname libcatlas.so -o libcatlas.so \
+	ld $(LDFLAGS) -shared -soname libcatlas.so.3gf.0 -o libcatlas.so.3gf.0 \
         --whole-archive libclapack_atlas.a libptcblas.a libatlas.a \
         --no-whole-archive -lc $(LIBS)
 fat_cshared : libclapack_atlas.a                  # unthreaded target
-	ld $(LDFLAGS) -shared -soname libcatlas.so -o libcatlas.so \
+	ld $(LDFLAGS) -shared -soname libcatlas.so.3gf.0 -o libcatlas.so.3gf.0 \
         --whole-archive libclapack_atlas.a libcblas.a libatlas.a \
         --no-whole-archive -lc $(LIBS)
 
@@ -135,10 +186,10 @@
            -Wl,--rpath ./
 
 xtry_lp:
-	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/qr.c libatlas.so -Wl,--rpath ./
+	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/qr.c libatlas.so.3gf.0 -Wl,--rpath ./
 xtry :
-	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/test_dynlink.c libatlas.so \
+	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/test_dynlink.c libatlas.so.3gf.0 \
            -Wl,--rpath ./
 xtry_c :
-	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/test_dynlink.c libcatlas.so \
+	$(ICC) $(CDEFS) -o $@ $(mySRCdir)/test_dynlink.c libcatlas.so.3gf.0 \
            -Wl,--rpath ./
